package com.beici;

import java.util.*;

/**
 * @auther WaterGhost
 * @date 2022/3/23 18:14
 */
class NullExecpet extends RuntimeException{
    public NullExecpet(String message) {
        super(message);
    }
}
public class test {
    // 定义输入
    static Scanner sc = new Scanner(System.in);
    // 定义电影总位置
    static int roomSum;
    // 定义电影位置渲染
    static char [][] room;
    // 行
    static int row ;
    // 列
    static int col;
    // 总收入
    static int numberSum;
    // 卖出的票价
    static int sellPrice;

    public static void main(String[] args) {
        // 用户输入 行列 定义 电影院位置
        row = sc.nextInt();
        col = sc.nextInt();
        room = new char[row][col];
        // 总数赋值
        roomSum = row * col;
        // 所有电影待定
        for (int i = 0; i < room.length; i++) {
            for (int i1 = 0; i1 < room[i].length; i1++) {
                // 待定
                room[i][i1] = 'O';
            }
        }
        while (true){
            int i = sc.nextInt();
            switch (i){
                case 1: print();break;
                case 2: ticket();break;
                case 3: statisical();break;
                case 4:return;
            }
        }
    }
    // 统计
    private static void statisical(){
        System.out.println("售出的总票数："+sellPrice);
        // 已数量 / 总数 * 100
        System.out.println("百分比："+((sellPrice/roomSum)*100));
        System.out.println("当前收入：$"+numberSum);
        // 算出前排
        int qian = (int) row / 2;
        int hou = row - qian;
        // 算出后排
        System.out.println("总收入：$"+(((qian*10)*col)+((hou*8))*col));
    }
    private static void ticket() {
        // 输入行列
        int x = sc.nextInt();
        int y = sc.nextInt();
        // 判断当前票价还在不在
        char location;
        try{
             location=room[x-1][y-1] ;

        }catch (IndexOutOfBoundsException e){
            throw new NullExecpet("错误输入");
        }
        if (location=='X'){
            System.out.println("此座位已被购买");
            return;
        }
        room [x-1][y-1] = 'X';
        // 判断票价
        int n = (int) row / 2;
        if (x<n){
            System.out.println("票价:10元");
            numberSum+=10;
        }else{
            numberSum+=8;
            System.out.println("票价:8元");
        }
        sellPrice++;
        System.out.println();

        // 输出价格
    }

    // 打印电影院
    public static void  print(){
        System.out.println("座位排列表:");
        // 打印第一行
        System.out.print(" ");
        for (int i = 0; i <col ; i++) {
            System.out.print(" ");
            System.out.print((i+1));
        }
        System.out.println();
        // 渲染电影院
        for (int i = 0; i < room.length; i++) {
            System.out.print((i+1));
            for (int i1 = 0; i1 < room[i].length; i1++) {
                System.out.print(" ");
                System.out.print(room[i][i1]);
            }
            System.out.println();
        }
        System.out.println();
    }

static class ha{
    public static void main(String[] args) {
        ArrayDeque queue = new ArrayDeque();
        queue.push("sb");
    }
}
}
